﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MYZNMarking
{
    public partial class FrmLogin : Form
    {
        public FrmLogin()
        {
            InitializeComponent();
            this.cmb_User.DataSource = new string[] { "厂商", "管理员", "操作员" };
        }

        private void btn_Login_Click(object sender, EventArgs e)
        {
            switch (cmb_User.Text)
            {
                case "厂商":
                    if (txt_Password.Text == "789")
                    {
                        Program.User = "厂商";
                    }
                    else
                    {
                        MessageBox.Show("密码错误！请重新输入");
                        return;
                    }
                    break;
                case "管理员":
                    if (txt_Password.Text == "456")
                    {
                        Program.User = "管理员";
                    }
                    else
                    {
                        MessageBox.Show("密码错误！请重新输入");
                        return;
                    }
                    break;
                case "操作员":
                    if (txt_Password.Text == "123")
                    {
                        Program.User = "操作员";
                    }
                    else
                    {
                        MessageBox.Show("密码错误！请重新输入");
                        return;
                    }
                    break;
                default:
                    return;
            }
            if (Program.User.Length >= 2)
            {
                this.DialogResult = DialogResult.OK;
            }

        }

        private void cmb_User_SelectedIndexChanged(object sender, EventArgs e)
        {
            txt_Password.Text = string.Empty;
        }
    }
}

